#include "mainwindow.h"

#include <QApplication>
#include<QTimer>
#include"myobject.h"

QEvent::Type CustomEvent::CustomEventType = static_cast<QEvent::Type>(QEvent::registerEventType());

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    //接收自定义事件的对象
    MyObject *myObject=new MyObject;

    //生成自定义事件
    CustomEvent *event = new CustomEvent(42);

    //发送事件
    QCoreApplication::postEvent(myObject, event);//异步，非阻塞
    //QCoreApplication::postEvent(myObject, event);//同步，阻塞
    return a.exec();
}
